#pragma once
#include <highgui.h>

namespace frameExtractor
{
	void extruct(char* aviFileName, char* dir)
	{
		CvCapture* capture = cvCaptureFromAVI(aviFileName);

		cvNamedWindow("frameExtractor");
		char b;
		bool isLeft = true;
		int count = 0;
		do
		{
			IplImage* img = cvQueryFrame(capture);
			cvShowImage("frameExtractor", img);

			b = cvWaitKey(0);
			if (b == 's')
			{
				char buff[1024];
				if (isLeft)
					sprintf(buff,"%s\\%i_left.png", dir, count);
				else
					sprintf(buff,"%s\\%i_right.png", dir, count++);

				isLeft = !isLeft;
				cvSaveImage(buff, img);
				printf("Image Saved to: %s\r\n", buff);
			}
		} while (b != 27);

		cvDestroyWindow("frameExtractor");
		cvReleaseCapture(&capture);
	}

};